@extends('layout.default')

@section('layout.content')

  <div class="row">
    @foreach( $activities as $activity)
      <div class="col-xs-12 col-sm-6 col-md-4 channel-row">

        <div class="thumbnail search-thumbnail channel-href" data-aid="{{$activity->id}}">

          <div class="caption">
            <div class="panel-title"><a
                  href="{{ route('activity.edit',array('id'=>$activity->id)) }}">{!! $activity->present()->showtitle !!}</a>
            </div>
            <div class="panel-body channel-property">
              <div class="panel-l">{!! $activity->present()->showtime !!}</div>
            </div>
            <div class="panel-body">
              <div class="panel-30"><a href="{{route('activity.show', array('aid'=>$activity->id,'action'=>'reader'))}}"
                                       class="blue">{{$activity->reader()->count()}}</a>
                <p>报名</p></div>
              <div class="panel-30"><a
                    href="{{route('activity.show', array('aid'=>$activity->id,'action'=>'volunteer'))}}"
                    class="pink2">{{$activity->volunteer()->count()}}</a>
                <p>志愿者</p></div>
              <div class="panel-30"><a href="{{route('activity.show', array('aid'=>$activity->id,'action'=>'checks'))}}"
                                       class="green">{{$activity->checks()->count()}}</a>
                <p>签到</p></div>
            </div>
            <div class="panel-body panel-bottom">
              <div class="panel-lf5 dropdown-toggle" data-toggle="dropdown"
                   href="#">{!! $activity->present()->actStatus !!}</div>
              <ul class="dropdown-menu dropdown-yellow">
                {!! $activity->present()->dropdown !!}
                <li class="act-sign">
                  <a><span class="pink"><i class="ace-icon fa fa-edit bigger-120"></i>&nbsp;活动补签</span></a>
                </li>
              </ul>
              <div class="panel-rf5">{!! $activity->present()->actShow !!}</div>
            </div>

          </div>

        </div>
      </div>
    @endforeach

  </div><!-- /.row -->
  <div class="row">
    <div class="col-xs-12">
      <div class="dataTables_paginate paging_bootstrap">
        {{$activities->links()}}
      </div>
    </div>
  </div>

@stop

@section('javascript')
  <script type="text/javascript">
      $(function () {

          $('.act-start').on('click', function () {
              var that = $(this);
              var aid = that.parents('.thumbnail').data('aid');
              var uri = aid + '/status';

              $.post(uri, {
                  '_token': $("input[name='_token']").attr('value'),
                  'status': 1
              }, function (data) {
                  layer.msg(data.message, {shift: -1}, function () {
                      if (data.status === true) {
                          that.parents('.panel-bottom').find('.panel-lf5').html('<span class="green"><i class="ace-icon fa fa-play bigger-120"></i>&nbsp;进行中</span>');
                          that.remove();
                      }
                  });
              }, 'json').error(function (data) {
                  layer.msg(data.responseJSON.message);
              });

          });


          $('.act-end').on('click', function () {
              var that = $(this);
              var aid = that.parents('.thumbnail').data('aid');
              var uri = aid + '/status';
              $.post(uri, {
                  '_token': $("input[name='_token']").attr('value'),
                  'status': -1
              }, function (data) {
                  layer.msg(data.message, {shift: -1}, function () {
                      if (data.status === true) {
                          that.parents('.panel-bottom').find('.panel-lf5').html('<span class="grey"><i class="ace-icon fa fa-stop bigger-120"></i>&nbsp;已结束</span>');
                          that.remove();
                      }
                  });
              }, 'json').error(function (data) {
                  layer.msg(data.responseJSON.message);
              });

          });


      });
  </script>
@stop